var fetchData = function (text, data, callback) {
    // alert(1);
    var myUrl = 'http://fanyi.youdao.com/openapi.do?keyfrom=llhhll&key=1100077056&type=data&doctype=json&version=1.1&q='+text;
    var url = 'http://localhost:2000?myUrl=' + myUrl;
    // ajax请求不用写回调,内部会帮我们创建一个回调函数,名字随机,每次都不一样
    $.ajax({
        type: 'get',
        dataType: 'jsonp',
        url: url,
        success: function(data) {
            // console.log(typeof)
            callback(data);
            console.log(data);
        },
        error: function(e) {
            alert('请查询输入的内容是否正确');
            callback(e);
            console.log(e);
        }
    });

};

module.exports = {
    fetchData: fetchData
};

// http://fanyi.youdao.com/openapi.do?keyfrom=<keyfrom>&key=<key>&type=data&doctype=json&version=1.1&q=goo
// http://fanyi.youdao.com/openapi.do?keyfrom=llhhll&key=1100077056&type=data&doctype=json&version=1.1&q=hi
// http://localhost:2000/?myUrl=//fanyi.youdao.com/openapi.do?keyfrom=llhhll&key=1100077056&type=data&doctype=json&version=1.1&q=222&callback=JSON_CALLBACK